<?php
var_dump($_GET);
var_dump($_POST);
//1.连接数据库
$link = @mysql_connect('localhost','root','root');
//2.判断连接是否成功
if(!$link){
	die('连接失败');
}
//3.选择数据库
mysql_select_db('team4');
//4.设置字符集
mysql_set_charset('utf8');
//5.准备sql语句
	// $title = $_POST['title'];
	// $author = $_POST['author'];
	// $content = $_POST['content'];
	// $id = $_POST['id'];
	// $sql = "update liuyan set title='$title',author='$author',content='$content' where id=$id";
	// echo $sql;

	//update liuyan set title='测试测试1111',author='测试测试111',content='测试测试1111' where id=16
	$arr = array();
	foreach($_POST as $k=>$v){
		if($k!='id'){
			$arr[] = "$k='$v'";
		}
	}

	$sql = "update liuyan set ".implode(',',$arr)." where id=".$_POST['id'];
//发送sql语句
$bool = mysql_query($sql);
//判断bool值
if($bool){
	echo '<script>alert("更改成功！");window.location.href="index.php"</script>';
}else{
	echo '<script>alert("更改失败！");window.location.href="index.php"</script>';
}